class StudentManagementSystem:
    def __init__(self):
        self.students = []
        self.next_id = 1

    def display_menu(self):
        """显示系统菜单"""
        print("\n" + "=" * 30)
        print("    学生管理系统 V10.0")
        print("=" * 30)
        print("1. 添加学生信息")
        print("2. 删除学生信息")
        print("3. 修改学生信息")
        print("4. 查询所有学生信息")
        print("5. 退出系统")
        print("=" * 30)

    def add_student(self):
        """添加学生信息"""
        print("\n--- 添加学生信息 ---")
        name = input("请输入学生姓名: ")
        gender = input("请输入学生性别: ")
        age = input("请输入学生年龄: ")
        major = input("请输入学生专业: ")

        student = {
            'id': self.next_id,
            'name': name,
            'gender': gender,
            'age': age,
            'major': major
        }

        self.students.append(student)
        self.next_id += 1
        print(f"成功添加学生: {name} (ID: {student['id']})")

    def delete_student(self):
        """删除学生信息"""
        print("\n--- 删除学生信息 ---")
        if not self.students:
            print("当前系统中没有学生信息!")
            return

        student_id = input("请输入要删除的学生ID: ")
        try:
            student_id = int(student_id)
        except ValueError:
            print("请输入有效的数字ID!")
            return

        for i, student in enumerate(self.students):
            if student['id'] == student_id:
                deleted_name = student['name']
                self.students.pop(i)
                print(f"成功删除学生: {deleted_name} (ID: {student_id})")
                return

        print(f"未找到ID为 {student_id} 的学生!")

    def modify_student(self):
        """修改学生信息"""
        print("\n--- 修改学生信息 ---")
        if not self.students:
            print("当前系统中没有学生信息!")
            return

        student_id = input("请输入要修改的学生ID: ")
        try:
            student_id = int(student_id)
        except ValueError:
            print("请输入有效的数字ID!")
            return

        for student in self.students:
            if student['id'] == student_id:
                print(f"当前学生信息: {student}")
                print("请输入新的学生信息 (直接回车保持原值):")

                new_name = input(f"姓名 [{student['name']}]: ") or student['name']
                new_gender = input(f"性别 [{student['gender']}]: ") or student['gender']
                new_age = input(f"年龄 [{student['age']}]: ") or student['age']
                new_major = input(f"专业 [{student['major']}]: ") or student['major']

                student['name'] = new_name
                student['gender'] = new_gender
                student['age'] = new_age
                student['major'] = new_major

                print(f"成功修改学生信息 (ID: {student_id})")
                return

        print(f"未找到ID为 {student_id} 的学生!")

    def show_all_students(self):
        """显示所有学生信息"""
        print("\n--- 所有学生信息 ---")
        if not self.students:
            print("当前系统中没有学生信息!")
            return

        print(f"{'ID':<5} {'姓名':<10} {'性别':<5} {'年龄':<5} {'专业':<15}")
        print("-" * 50)
        for student in self.students:
            print(
                f"{student['id']:<5} {student['name']:<10} {student['gender']:<5} {student['age']:<5} {student['major']:<15}")

    def run(self):
        """运行学生管理系统"""
        print("欢迎使用学生管理系统 V10.0!")

        while True:
            self.display_menu()
            choice = input("请选择操作 (1-5): ")

            if choice == '1':
                self.add_student()
            elif choice == '2':
                self.delete_student()
            elif choice == '3':
                self.modify_student()
            elif choice == '4':
                self.show_all_students()
            elif choice == '5':
                print("感谢使用学生管理系统，再见!")
                break
            else:
                print("无效选择，请输入1-5之间的数字!")


# 启动系统
if __name__ == "__main__":
    system = StudentManagementSystem()
    system.run()